<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateQiiArticleCategoryTable extends Migration
{
    /**
     * Schema table name to migrate
     * @var string
     */
    public $set_schema_table = 'qii_article_category';

    /**
     * Run the migrations.
     * @table qii_article_category
     *
     * @return void
     */
    public function up()
    {
        if (Schema::hasTable($this->set_schema_table)) return;
        Schema::create($this->set_schema_table, function (Blueprint $table) {
            $table->engine = 'InnoDB';
            $table->increments('id')->comment('类别ID');
            $table->char('alias', 20)->default('')->comment('类别别名 (可代替ID进行URL的优化)');
            $table->string('name', 180)->default('')->comment('类别名称');
            $table->string('litpic', 180)->default('')->comment('类别默认缩略图 (如数据未设置缩略图则默认显示此图)');
            $table->unsignedInteger('litpic_width')->default('0')->comment('类别默认缩略图宽度');
            $table->unsignedInteger('litpic_height')->default('0')->comment('类别默认缩略图高度');
            $table->text('router')->comment('前台路由规则');
            $table->longText('data')->comment('类别自定义数据 (可以按需保存)');
            $table->unsignedInteger('parent_id')->default('0')->comment('上级类别ID');
            $table->unsignedInteger('top_id')->default('0')->comment('顶级类别ID');
            $table->unsignedInteger('type_id')->default('0')->comment('数据类型ID');
            $table->unsignedInteger('timer')->default('0')->comment('时间显示');
            $table->unsignedInteger('type_tpl_content')->default('0')->comment('数据模板ID(内容页)');
            $table->text('type_tpl_contents')->comment('数据可选模板ID(半角逗号分隔多个模板ID)');
            $table->unsignedInteger('type_tpl_list')->default('0')->comment('数据模板ID(列表页)');
            $table->unsignedTinyInteger('is_show_list')->default('0')->comment('是否显示列表页');
            $table->unsignedTinyInteger('is_show_content')->default('0')->comment('是否显示内容页');
            $table->unsignedTinyInteger('is_allow_select_content_tpl')->default('0')->comment('内容页是否可以选择不同模板');
            $table->unsignedInteger('pagesize')->default('10')->comment('列表页每页显示数据条数');
            $table->unsignedInteger('wap_pagesize')->default('6')->comment('手机列表页每页显示数据条数');
            $table->text('seo')->comment('SEO设置');
            $table->unsignedTinyInteger('is_sys')->default('0')->comment('系统类别');
            $table->unsignedInteger('site_id')->default('0')->comment('站点ID');
            $table->unsignedInteger('lang_id')->default('0')->comment('语言版本ID');
            $table->unsignedInteger('sortrank')->default('0')->comment('排序');
            $table->unsignedTinyInteger('is_dev')->default('0')->comment('是否用于开发人员部署目录结构(此类分类不允许非开发人员维护:1是,0否)');
            $table->unsignedInteger('modified')->default('0')->comment('添加/修改时间');

            $table->index(["alias"], 'alias');

            $table->index(["parent_id", "is_dev"], 'parent_dev');

            $table->index(["site_id", "sortrank"], 'site_sortrank');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
     public function down()
     {
       Schema::dropIfExists($this->set_schema_table);
     }
}
